package net.openl10n.api.document;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlType;

import net.openl10n.api.Namespaces;

@XmlType(name="containerType", namespace=Namespaces.DOCUMENT)
public class Container extends Resource {
	
	private List<Resource> content;
	private String lang;
	
	public Container() {
	}
	
	public Container(String id) {
		super(id);
	}
	
	public Container(String id, String lang) {
		this(id);
		this.lang = lang;
	}

	@XmlAttribute(name="lang", namespace=Namespaces.XML, required=true)
	public String getLang() {
		return lang;
	}
	
	public void setLang(String lang) {
		this.lang = lang;
	}
	
	@XmlElementWrapper(name="content", namespace=Namespaces.DOCUMENT, required=true)
	@XmlElements({
		@XmlElement(name="text-flow", type=TextFlow.class, namespace=Namespaces.DOCUMENT),
		@XmlElement(name="container", type=Container.class, namespace=Namespaces.DOCUMENT),
		@XmlElement(name="reference", type=Reference.class, namespace=Namespaces.DOCUMENT),
		@XmlElement(name="data-hook", type=DataHook.class, namespace=Namespaces.DOCUMENT)
		})
	public List<Resource> getContent() {
		if(content == null)
			content = new ArrayList<Resource>();
		return content;
	}
	
}
